home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 1833 / 1833.xpi / chrome / m / yoono.com / sidebar.jar / sidebar / js / externalIframeManager.js < prev    next >
Text File  |  2009-12-16  |  6KB  |  1 lines

  1. function ExternalIframeManager(){this._startUrl="http://www.yoono.com/sb/uninitializedYoodget.html";this._webUrl="http://www.yoono.com/sb/uninitializedYoodget.html";this.cssPath="";this.autoRefresh=false;this.insertPosition="first";this._wrapperUrl="chrome://yoonosb/content/wrapper.xul";this._iframe=null;this._iframeContent=null;this._doc=null;this._refreshTimer=null;this._sep="?";this._yoodget=null;this._id="";this._visible=false;this._title="";this.hostForCookies=""}ExternalIframeManager.prototype.IFRAME_SHOWN="EXTERNAL_IFRAME_SHOWN";ExternalIframeManager.prototype.IFRAME_HIDDEN="EXTERNAL_IFRAME_HIDDEN";ExternalIframeManager.prototype.SET_TITLE="EXTERNAL_IFRAME_SET_TITLE";ExternalIframeManager.prototype.DOCUMENT_LOADED="EXTERNAL_IFRAME_DOCUMENT_LOADED";ExternalIframeManager.prototype.getContentIframe=function(){return(this._iframeContent)};ExternalIframeManager.prototype.getIframe=function(){return(this._iframe)};ExternalIframeManager.prototype.getDoc=function(){return(this._doc)};ExternalIframeManager.prototype.getYoodget=function(){return(this._yoodget)};ExternalIframeManager.prototype.isVisible=function(){return(this._visible)};ExternalIframeManager.prototype.getTitle=function(){return(this._title)};ExternalIframeManager.prototype.getId=function(){return(this._id)};ExternalIframeManager.prototype.getWebUrl=function(){return(this._webUrl)};ExternalIframeManager.prototype.init=function(b,d,f){try{this._id=f;this._yoodget=d;if(this.hostForCookies){d.YEXTIF.execFct("allowCookiesForHost",this.hostForCookies)}if(this._startUrl.indexOf("?")!=-1){this._sep="&"}if(!b){throw ("ExternalIframeManager.init: Iframe Container could not be found")}this._div=document.createElement("div");this._div.setAttribute("style","position:absolute;top:0;left:0;right:0;height:0");this._iframe=yoono.dom.createElementNS(document,"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul","iframe");this._iframeContent=this._iframe;this._div.appendChild(this._iframe);this._iframe.setAttribute("src","about:blank");this._iframe.setAttribute("type","content");this._iframe.setAttribute("style","position:absolute;top:0;left:0;right:0;bottom:0;width:100%; height: 100%");if((this.insertPosition=="last")||(!b.firstChild)){b.appendChild(this._div)}else{b.insertBefore(this._div,b.firstChild)}var a=this;yoono.event.addEventListener(this._iframe,"load",function(e){a.iframeLoaded(e)},true);yoono.event.addEventListener(this._iframe,"click",function(e){a.checkIfLink(e)},true);if(document.all){this._iframe.setAttribute("src",this._startUrl)}else{this._iframe.setAttribute("src",this._wrapperUrl)}}catch(c){alert(c);logError("ExternalIframeManager.init: "+c)}};ExternalIframeManager.prototype.showIframe=function(){this._div.style.height="100%";this._div.style.opacity="1";this._visible=true;this.onShowing();this.getYoodget().notify(ExternalIframeManager.prototype.IFRAME_SHOWN,this)};ExternalIframeManager.prototype.hideIframe=function(){this._div.style.height="0";this._div.style.opacity="0";this._visible=false;this.onHiding();this.getYoodget().notify(ExternalIframeManager.prototype.IFRAME_HIDDEN,this)};ExternalIframeManager.prototype.onShowing=function(){};ExternalIframeManager.prototype.onHiding=function(){};ExternalIframeManager.prototype.setTitle=function(a){this._title=a;this.getYoodget().notify(ExternalIframeManager.prototype.SET_TITLE,this)};ExternalIframeManager.prototype.iframeLoaded=function(b){if(document.all){this._doc=this._iframe.contentWindow.document;this.documentLoaded()}else{var c=this._iframeContent.getAttribute("src");if(c==this._wrapperUrl){var d=this._iframe.contentWindow.document;var a=this;this._iframeContent=d.getElementById("wrapperIframe").wrappedJSObject;this._iframeContent.setAttribute("src",this._startUrl)}else{this._doc=this._iframeContent.contentWindow.document;if(!this._doc.body){return}this.documentLoaded()}}};ExternalIframeManager.prototype.documentLoaded=function(){try{clearInterval(this.refreshTimer);this._doc.body.style.display="none";var b=this._doc.getElementsByTagName("head");if(b&&b[0]){var a=this._doc.createElement("link");a.setAttribute("type","text/css");a.setAttribute("rel","stylesheet");var c=this._yoodget.importUrl+"/"+this.cssPath;a.setAttribute("href",c);b[0].appendChild(a)}this._doc.body.style.display="block";this.setAutoRefresh();this.afterDocumentLoaded();this.getYoodget().notify(ExternalIframeManager.prototype.DOCUMENT_LOADED,this)}catch(d){logError("ExternalIframeManager: "+d)}};ExternalIframeManager.prototype.afterDocumentLoaded=function(){};ExternalIframeManager.prototype.setAutoRefresh=function(){var a=this;if(!this.autoRefresh){return}var b=this.getRefreshInterval();if(b){var b=b*1000*60;if(b){this.refreshTimer=setTimeout(function(){a.reloadStartDocument()},b)}}};ExternalIframeManager.prototype.getRefreshInterval=function(){return(0)};ExternalIframeManager.prototype.reloadStartDocument=function(a){clearInterval(this.refreshTimer);if(a||this.canRefreshNow()){this._iframeContent.setAttribute("src",this._startUrl+this._sep+"yoonourltstamp="+new Date().getTime())}this.setAutoRefresh()};ExternalIframeManager.prototype.canRefreshNow=function(){var b=this._doc.location.href;var a=b.indexOf(this._sep+"yoonourltstamp");if(a!=-1){b=b.substr(0,a)}return(this._startUrl==b)};ExternalIframeManager.prototype.checkIfLink=function(a){var c=Event.element(a);if("A"==c.nodeName){var b=c.getAttribute("href");if(this.isExternalLink(b)){this._yoodget.YEXTIF.execFct("openUrl",[b]);Event.stop(a)}}};ExternalIframeManager.prototype.isExternalLink=function(b){var a=false;if(0==b.indexOf("http://")){a=true}return(a)};ExternalIframeManager.prototype.finalize=function(a){clearInterval(this.refreshTimer)};ExternalIframeManager.prototype.setStartUrl=function(a){this._startUrl=a};